package action;

import data.Float2;

public class MovimentAction extends Action<Float2> {

	// Overload.
	public void start(float targetX, float targetY, float inputX, float inputY, float time)
	{
		this.start(new Float2(targetX, targetY), new Float2(inputX, inputY), time);
	}
	
	
	//###################################### MOVEMENT METHODS ##########################################################
	public void moveUp(float amount, Float2 input, float time)
	{ 
		this.start(new Float2(input.getF1()         , input.getF2() - amount), input, time);
	}
	public void moveDown(float amount, Float2 input, float time)
	{
		this.start(new Float2(input.getF1()         , input.getF2() + amount), input, time);
	}
	public void moveLeft(float amount, Float2 input, float time)
	{
		this.start(new Float2(input.getF1() - amount, input.getF2()         ), input, time);
	}
	public void moveRight(float amount, Float2 input, float time)
	{ 
		this.start(new Float2(input.getF1() + amount, input.getF2()         ), input, time);
	}
	//################################## END MOVEMENT METHODS ##########################################################
	
	
	@Override
	Float2 update() {
		if (internalTime > time)
		{
			running = false;
			finished = true;
			return target;
		}
		else
		{
			Float2 output = new Float2();
			output.setF1(input.getF1() + (target.getF1() - input.getF1()) * (internalTime / time));
			output.setF2(input.getF2() + (target.getF2() - input.getF2()) * (internalTime / time));
			return output;
		}
	}
}
